import Vue from 'vue'
import App from './App.vue'
import router from './router'
import { Button, Field, Form, Tabbar, TabbarItem } from 'vant'

Vue.use(Button)
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Form)
Vue.use(Field)
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

const isLogin = true // 登录状态(未登录)
router.beforeEach((to, from, next) => {
  if (to.path === '/login' && isLogin === false) {
    alert('请登录')
    next(false) // 阻止路由跳转
  } else {
    next() // 正常放行
  }
})
